#ifndef FINDERPATTERN_H
#define FINDERPATTERN_H

#include <iostream>
#include <QImage>
#include <vector>
#include <cmath>

#include "point.h"
#include "pixel.h"
#include "canvas.h"
#include "converter.h"

using namespace std;

class finderpattern
{

public:
    finderpattern();
    void findFinders (QImage *img);
    void paintFinders (int pixelProportion, QImage *img);

    point getUpperLeftFinder ();
    point getUpperRightFinder ();
    point getLowerLeftFinder ();
    float getAngle ();

    void setCanvas (canvas *log);

private:
    point upperLeftFinder;
    point upperRightFinder;
    point lowerLeftFinder;
    float angle;

    canvas *log;

    point selectBestFinder (vector<point> pointList);
    void calculateAngle ();
    vector<point> checkHorizontalUpLeft (int rowStart, int rowEnd, QImage *img);
    vector<point> checkHorizontalDownLeft (int rowStart, int rowEnd, QImage *img);
    vector<point> checkHorizontalUpRight (int rowStart, int rowEnd, QImage *img);
    bool crossCheckVertical (int startRow, int startCol, QImage *img);
    bool checkRatio (int stateCount[]);
};

#endif // FINDERPATTERN_H
